{% extends "PC/template.html" %}

{% block title %}
{% endblock %}

{% block css %}
{% endblock %}


{% block content %}

<input type="file" id="update_img">
{% endblock %}

{% block js %}
<script>
    let update_img = document.getElementById('update_img');
    update_img.onchange = function () {
        let file = update_img.files[0];
        console.log(file);
        const formData = new FormData();
        formData.append('file', file);

        axios.post('/api/TengXunYuanBao/file/update_file/', formData, {
            headers: {
                'Content-Type': 'multipart/form-data',
                'X-CSRFToken': get_csrfmiddlewaretoken()
            }
        }).then(response => {
            console.log('上传成功', response.data);
        }).catch(error => {
            console.error('上传失败', error);
        });

    }
</script>
{% endblock %}